// license-header java merge-point
/**
 * This is only generated once! It will never be overwritten.
 * You can (and have to!) safely modify it by hand.
 */
package edu.uwlax.cs.oayonlinestore.entities;

import java.util.Date;

/**
 * @see edu.uwlax.cs.oayonlinestore.entities.User
 */
public class UserDaoImpl extends
		edu.uwlax.cs.oayonlinestore.entities.UserDaoBase {
	/**
	 * @see edu.uwlax.cs.oayonlinestore.entities.UserDao#toUserVO(edu.uwlax.cs.oayonlinestore.entities.User,
	 *      edu.uwlax.cs.oayonlinestore.vo.UserVO)
	 */
	public void toUserVO(edu.uwlax.cs.oayonlinestore.entities.User source,
			edu.uwlax.cs.oayonlinestore.vo.UserVO target) {
		super.toUserVO(source, target);
	}

	/**
	 * Retrieves the entity object that is associated with the specified value
	 * object from the object store. If no such entity object exists in the
	 * object store, a new, blank entity is created
	 */
	private edu.uwlax.cs.oayonlinestore.entities.User loadUserFromUserVO(
			edu.uwlax.cs.oayonlinestore.vo.UserVO userVO) {
		User user = this.load(userVO.getId());
		if (user == null)
			user = User.Factory.newInstance();
		return user;
	}

	/**
	 * @see edu.uwlax.cs.oayonlinestore.entities.UserDao#userVOToEntity(edu.uwlax.cs.oayonlinestore.vo.UserVO)
	 */
	public edu.uwlax.cs.oayonlinestore.entities.User userVOToEntity(
			edu.uwlax.cs.oayonlinestore.vo.UserVO userVO) {
		// @todo verify behavior of userVOToEntity
		edu.uwlax.cs.oayonlinestore.entities.User entity = this
				.loadUserFromUserVO(userVO);
		this.userVOToEntity(userVO, entity, true);
		return entity;
	}

	/**
	 * @see edu.uwlax.cs.oayonlinestore.entities.UserDao#userVOToEntity(edu.uwlax.cs.oayonlinestore.vo.UserVO,
	 *      edu.uwlax.cs.oayonlinestore.entities.User)
	 */
	public void userVOToEntity(edu.uwlax.cs.oayonlinestore.vo.UserVO source,
			edu.uwlax.cs.oayonlinestore.entities.User target, boolean copyIfNull) {
		// @todo verify behavior of userVOToEntity
		super.userVOToEntity(source, target, copyIfNull);
	}

	/**
	 * @see edu.uwlax.cs.oayonlinestore.entities.UserDao#toUserDetailsVO(edu.uwlax.cs.oayonlinestore.entities.User,
	 *      edu.uwlax.cs.oayonlinestore.vo.UserDetailsVO)
	 */
	public void toUserDetailsVO(
			edu.uwlax.cs.oayonlinestore.entities.User source,
			edu.uwlax.cs.oayonlinestore.vo.UserDetailsVO target) {
		super.toUserDetailsVO(source, target);

		// make sure the Date-object is not a Timestamp-object as it is used
		// along with SQL. GWT can't serialize Timestamp-objects.
		if (source.getCcExpirationDate() != null)
			target.setCcExpirationDate(new Date(source.getCcExpirationDate()
					.getTime()));
	}

	/**
	 * Retrieves the entity object that is associated with the specified value
	 * object from the object store. If no such entity object exists in the
	 * object store, a new, blank entity is created
	 */
	private edu.uwlax.cs.oayonlinestore.entities.User loadUserFromUserDetailsVO(
			edu.uwlax.cs.oayonlinestore.vo.UserDetailsVO userDetailsVO) {
		return loadUserFromUserVO(userDetailsVO);
	}

	/**
	 * @see edu.uwlax.cs.oayonlinestore.entities.UserDao#userDetailsVOToEntity(edu.uwlax.cs.oayonlinestore.vo.UserDetailsVO)
	 */
	public edu.uwlax.cs.oayonlinestore.entities.User userDetailsVOToEntity(
			edu.uwlax.cs.oayonlinestore.vo.UserDetailsVO userDetailsVO) {
		// @todo verify behavior of userDetailsVOToEntity
		edu.uwlax.cs.oayonlinestore.entities.User entity = this
				.loadUserFromUserDetailsVO(userDetailsVO);
		this.userDetailsVOToEntity(userDetailsVO, entity, true);
		return entity;
	}

	/**
	 * @see edu.uwlax.cs.oayonlinestore.entities.UserDao#userDetailsVOToEntity(edu.uwlax.cs.oayonlinestore.vo.UserDetailsVO,
	 *      edu.uwlax.cs.oayonlinestore.entities.User)
	 */
	public void userDetailsVOToEntity(
			edu.uwlax.cs.oayonlinestore.vo.UserDetailsVO source,
			edu.uwlax.cs.oayonlinestore.entities.User target, boolean copyIfNull) {
		// @todo verify behavior of userDetailsVOToEntity
		super.userDetailsVOToEntity(source, target, copyIfNull);
	}

}